home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
InsideBa1994
/
InsideBasic-94
/
IB 94
/
Sound Mover
/
Sound Mover.bas
next >
Wrap
BASIC Source File
|
1994-01-25
|
9KB
|
358 lines
WINDOW OFF:COORDINATE WINDOW
DEF MOUSE=-1:CURSOR 4:WIDTH -2
DEFSTR LONG
'==============================================================
'Resources
'==============================================================
RESOURCES "Sound Mover.res"
'==============================================================
'Equates
'==============================================================
DIM T,L,B,R
DIM My,Mx
True = NOT(False)
DIM FAsc,FDes,FWid,FLead,Fht
DIM 1 Cr$:Cr$= CHR$(13)
'
DIM ScrnT,ScrnL,ScrnB,ScrnR
CALL GETWMGRPORT(WMgrPort&)
BLOCKMOVE WMgrPort&+8,VARPTR(ScrnT),8
'
Arrow = 0
Watch = 4
Hand = 1000
'
ButtonAct = 1
RefreshAct = 5
'
DIM 63 FileName$(1)
DIM FileVol(1)
DIM FileResRef(1)
DIM TopItem(1)
DIM SelItem(1)
DIM ActiveSide
'
GOTO"Queue"
'
'==============================================================
'Functions
'==============================================================
'
LONG FN GetFht(GFFont,GFSize,GFFace,GFMode)
TEXT GFFont,GFSize,GFFace,GFMode
CALL GETFONTINFO(FAsc)
END FN = FAsc+FDes+FLead
'
LONG FN ShowList(WhichSide)
T = 31
LONG IF WhichSide
L = 265:R = 394
XELSE
L = 21:R = 150
END IF
Fht = FN GetFht(0,12,0,0)
B = T + Fht
LONG IF LEN(FileName$(WhichSide))
StartElem = TopItem(WhichSide) + 1
FOR F = StartElem TO StartElem + 5
Temp$ = INDEX$(F,WhichSide)
CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
LONG IF F = SelItem(WhichSide)
LONG IF WhichSide = ActiveSide
CALL BITCLR(#&938,0)
CALL INVERTRECT(T)
END IF
END IF
CALL OFFSETRECT(T,0,Fht)
NEXT
B = 126
XELSE
B = 126
CALL ERASERECT(T)
END IF
T=31
CALL INSETRECT(T,-1,-1)
CALL FRAMERECT(T)
Max = MEM(10+WhichSide)-6
IF Max < 1 THEN Max = 1
SCROLL BUTTON WhichSide+3,TopItem(WhichSide)+1,1,Max
END FN
'
LONG FN ShowErr(TheMsg$)
CALL PARAMTEXT(TheMsg$,"","","")
X=FN STOPALERT(1,0)
END FN
'
LONG FN CloseFile(WhichSide)
LONG IF LEN(FileName$(WhichSide))
LONG IF FileResRef(WhichSide)>0
CALL CLOSERESFILE(FileResRef(WhichSide))
END IF
END IF
FileName$(WhichSide) = ""
FileResRef(WhichSide) = 0
FN ShowList(WhichSide)
GOSUB"Fix Buttons"
BUTTON WhichSide+1,1,"Open"
END FN
'
LONG FN OpenFile(WhichSide)
LONG IF LEN(FileName$(WhichSide))
FN CloseFile(WhichSide)
XELSE
Temp$ = FILES$(1,"",,Vol)
LONG IF LEN(Temp$)
SELECT Temp$
CASE PSTR$(&910) 'cur app
TheRef = -2
FN ShowErr("This utility can't open itself.")
CASE PSTR$(&AD8) 'system file
TheRef = -3
FN ShowErr("This utility can't open the System file.")
CASE ELSE
TheRef = FN OPENRFPERM(Temp$,Vol,3)
END SELECT
LONG IF TheRef < 0
LONG IF TheRef = -1
FN ShowErr("This file does not have a resource fork.")
END IF
XELSE
TheCount = FN COUNT1RESOURCES(CVI("snd "))
LONG IF TheCount = 0
FN ShowErr("This file doesn't have any sounds.")
XELSE
FileName$(WhichSide) = Temp$
FileResRef(WhichSide) = TheRef
FileVol(WhichSide) = Vol
TopItem(WhichSide) = 0
SelItem(WhichSide) = 1
ActiveSide = WhichSide
CLEAR INDEX$ WhichSide
CLEAR 5000,WhichSide
FOR F = 1 TO TheCount
SndHndl& = FN GET1INDRESOURCE(CVI("snd "),F)
LONG IF SndHndl&
CALL GETRESINFO(SndHndl&,ID,Type&,Temp$)
LONG IF Temp$ = ""
Temp$ = "ID "+STR$(ID)
END IF
INDEX$(F,WhichSide) = Temp$
END IF
NEXT
BUTTON WhichSide + 1,1,"Close"
SelItem(WhichSide) = 1
FN ShowList(WhichSide)
GOSUB"Fix Buttons"
GOSUB"Show File Names"
END IF
END IF
END IF
END IF
END FN
'
LONG FN GetSound
Temp$ = INDEX$(SelItem(ActiveSide),ActiveSide)
CurRes = FN CURRESFILE
CALL USERESFILE(FileResRef(ActiveSide))
SndHndl& = FN GET1NAMEDRESOURCE(CVI("snd "),Temp$)
LONG IF SndHndl& = 0
ID = VAL(MID$(Temp$,3))
SndHndl& = FN GET1RESOURCE(CVI("snd "),ID)
END IF
CALL USERESFILE(CurRes)
END FN = SndHndl&
'
LONG FN AutoCursor(Fy,Fx)
ACResult = Arrow
LONG IF WINDOW(0)
ACPort& = WINDOW(14)
LONG IF ACPort&
LONG IF FN FINDCONTROL(Fy,ACPort&,ACHndl&)
ACResult = Hand
END IF
END IF
END IF
END FN = ACResult
'==============================================================
"Queue"
'==============================================================
GOSUB"Build"
ON BREAK GOSUB"Break"
ON DIALOG GOSUB"Dialog"
ON MOUSE GOSUB"Mouse"
CURSOR Arrow
'
'==============================================================
"Loop"
'==============================================================
'
DIALOG ON :MOUSE ON :BREAK ON
' The only place events are trapped
DIALOG OFF:MOUSE OFF:BREAK OFF
'
OldCsr=NewCsr
NewCsr=Arrow
CALL GETMOUSE(My)
NewCsr=FN AutoCursor(My,Mx)
IF NewCsr<>OldCsr THEN CURSOR NewCsr
'
LONG IF KissOfDeath
IF ResRef>0 THEN CALL CLOSERESFILE(ResRef)
END
END IF
GOTO"Loop"
'
'==============================================================
"Dialog"
'==============================================================
Act=DIALOG(0):Ref=DIALOG(Act)
'
IF Act=RefreshAct THEN "Format Wnd"
'
LONG IF Act = ButtonAct
SELECT Ref
CASE 1,2:FN OpenFile(Ref-1) 'open
CASE 3,4 'scroll
WhichSide = Ref - 3
TopItem(WhichSide) = BUTTON(Ref)-1
FN ShowList(WhichSide)
CASE 5 'copy
SndHndl& = FN GetSound
LONG IF SndHndl&
CALL GETRESINFO(SndHndl&,ID,Type&,Temp$)
CALL DETACHRESOURCE(SndHndl&)
LONG IF ActiveSide
NewHome = 0
XELSE
NewHome = 1
END IF
CurRes = FN CURRESFILE
CALL USERESFILE(FileResRef(NewHome))
ID = FN UNIQUEID(CVI("snd "))
CALL ADDRESOURCE(SndHndl&,Type&,ID,Temp$)
CALL USERESFILE(CurRes)
IF Temp$ = "" THEN Temp$ = "ID "+STR$(ID)
LONG IF FN RESERROR = 0
INDEX$ I (1,NewHome) = Temp$
SelItem(NewHome) = 1
TopItem(NewHome) = 0
FN ShowList(NewHome)
END IF
END IF
CASE 6 'remove
SndHndl& = FN GetSound
LONG IF SndHndl&
CALL RMVERESOURCE(SndHndl&)
OSErr = FN DISPOSHANDLE(SndHndl&)
END IF
INDEX$ D(SelItem(ActiveSide),ActiveSide)
LONG IF SelItem(ActiveSide)>1
SelItem(ActiveSide) = SelItem(ActiveSide) - 1
END IF
FN ShowList(ActiveSide)
CASE 7 'play
SndHndl& = FN GetSound
IF SndHndl& THEN OSErr = FN SNDPLAY(0,SndHndl&,0)
CASE 8:GOSUB"Break" 'quit
END SELECT
END IF
RETURN
'==============================================================
"Mouse"
'==============================================================
Mact=MOUSE(0):Mx=MOUSE(1):My=MOUSE(2)
'
T=30:L=21:B=127:R=150
Found = False
SideWas = ActiveSide
LONG IF FN PTINRECT(My,T)
Found = 1
XELSE
L = 265:R = 394
LONG IF FN PTINRECT(My,T)
Found = 2
END IF
END IF
LONG IF Found
ActiveSide = Found - 1
LONG IF ActiveSide <> SideWas
FN ShowList(SideWas)
END IF
TheItem = (My - T)/Fht + TopItem(ActiveSide) + 1
LONG IF TheItem < MEM(10+ActiveSide)
LONG IF TheItem <> SelItem(ActiveSide) OR ActiveSide <> SideWas
SelItem(ActiveSide) = TheItem
FN ShowList(ActiveSide)
GOSUB"Fix Buttons"
END IF
END IF
END IF
IF FN BUTTON THEN "Mouse"
RETURN
'==============================================================
"Break"
'==============================================================
'
'
FN CloseFile(0)
FN CloseFile(1)
KissOfDeath = True
RETURN
'=================
"Build"
'=================
T = 0:L = 0:B = 180:R = 434: 'Set TLBR to window size
' Offset the rect to the center of the screen
CALL OFFSETRECT(T,ScrnR/2-R/2,(ScrnB/2+8)-B/2)
WINDOW 1,"",(L,T)-(R,B),-2
BUTTON 1, 1,"Open",( 20, 138)-( 166, 158),1
BUTTON 2, 1,"Open",( 264, 138)-( 410, 158),1
SCROLL BUTTON 3,1,1,10,6,( 150, 30)-( 166, 127),0
SCROLL BUTTON 4,1,1,10,6,( 394, 30)-( 410, 127),0
BUTTON 5, 0,"Copy",( 172, 30)-( 256, 50),1
BUTTON 6, 0,"Remove",( 172, 66)-( 256, 86),1
BUTTON 7, 0,"Play",( 172, 102)-( 256, 122),1
BUTTON 8, 1,"Quit",( 172, 138)-( 256, 158),1
RETURN
'=================
"Format Wnd"
'=================
GOSUB"Show File Names"
FN ShowList(0)
FN ShowList(1)
RETURN
'=================
"Show File Names"
'=================
TEXT 3,9,0,0
T = 12:L = 18:B = 24:R = 166
Temp$ = FileName$(0)
CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
L = 263:R = 411
Temp$ = FileName$(1)
CALL TEXTBOX(VARPTR(Temp$)+1,LEN(Temp$),T, 1)
RETURN
'=================
"Fix Buttons"
'=================
LONG IF LEN(FileName$(0)) AND LEN(FileName$(1))
LONG IF ActiveSide
Temp$ = "«Copy«"
XELSE
Temp$ = "»Copy»"
END IF
BUTTON 5,1,Temp$
XELSE
BUTTON 5,0
END IF
LONG IF LEN(FileName$(0)) OR LEN(FileName$(1))
BUTTON 6,1
BUTTON 7,1
XELSE
BUTTON 6,0
BUTTON 7,0
END IF
RETURN